import { ReactChild, ReactFragment, ReactPortal } from 'react';
import React, { Component } from 'react';
import request from 'umi-request';
import { Tag, Space } from 'antd';

// class tablist extends React.Component {
//   state = {
//     data: [],
//   };
//   //发送get请求获取数据
//   sublimt() {
//     request.get('http://127.0.0.1:3000/api/cs').then((nody) => {
//       console.log(nody);
//       if (nody.status == 200) {
//         console.log(nody.data.data);
//         const data = nody.data.data;
//         this.setState({
//           data: data,
//         });
//       }
//     });
//   }

//   componentDidMount() {
//     this.sublimt();
//   }

//   columns1 = [
//     {
//       title: '地址',
//       dataIndex: 'address',
//       key: 'address',
//       render: (
//         text:
//           | boolean
//           | ReactChild
//           | ReactFragment
//           | ReactPortal
//           | null
//           | undefined,
//       ) => <a>{text}</a>,
//     },
//     {
//       title: '东经',
//       dataIndex: 'pos_e',
//       key: 'pos_e',
//     },
//     {
//       title: '北纬',
//       dataIndex: 'pos_n',
//       key: 'pos_n',
//     },
//     {
//       title: '救援队名',
//       key: 'name',
//       dataIndex: 'name',
//     },

//     {
//       title: '救援队简介',
//       key: 'info',
//       dataIndex: 'info',
//     },
//     {
//       title: '认证信息',
//       dataIndex: 'prove',
//       key: 'prove',
//     },
//   ];
//   data1 = this.state.data;
//   // const data1 = [
//   //   {
//   //     address: '1',
//   //     pos_e: '胡彦斌',
//   //     pos_n: '32',
//   //     name: '<We></We>',
//   //     info: '西湖区湖底公园1号',
//   //     prove: '1',
//   //   },
//   // ];
// }
// export default tablist;
const columns1 = [
  {
    title: '救援队名',
    dataIndex: 'name',
    key: 'name',
    render: (
      text:
        | boolean
        | ReactChild
        | ReactFragment
        | ReactPortal
        | null
        | undefined,
    ) => <a>{text}</a>,
  },
  {
    title: '当前位置to目的地',
    dataIndex: 'age',
    key: 'age',
  },
  {
    title: '救援目标',
    dataIndex: 'address',
    key: 'address',
  },
  {
    title: '实时需求',
    key: 'tags',
    dataIndex: 'tags',
    render: (tags: any[]) => (
      <>
        {tags.map((tag) => {
          let color = tag.length > 5 ? 'geekblue' : 'green';
          if (tag === 'loser') {
            color = 'volcano';
          }
          return (
            <Tag color={color} key={tag}>
              {tag.toUpperCase()}
            </Tag>
          );
        })}
      </>
    ),
  },
  {
    title: 'Action',
    key: 'action',
    render: (
      text: any,
      record: {
        name:
          | boolean
          | ReactChild
          | ReactFragment
          | ReactPortal
          | null
          | undefined;
      },
    ) => (
      <Space size="middle">
        <a>Invite {record.name}</a>
        <a>Delete</a>
      </Space>
    ),
  },
];
const data1 = [
  {
    key: '1',
    name: '胡彦斌',
    age: 32,
    address: '西湖区湖底公园1号',
    tags: ['nice', 'developer'],
  },
  {
    key: '2',
    name: '长期&物资求助',
    age: 32,
    address: 'New York No. 1 Lake Park',
    tags: ['nice', 'developer'],
  },
  {
    key: '3',
    name: 'Jim Green',
    age: 42,
    address: 'London No. 1 Lake Park',
    tags: ['loser'],
  },
  {
    key: '4',
    name: 'Joe Black',
    age: 32,
    address: 'Sidney No. 1 Lake Park',
    tags: ['cool', 'teacher'],
  },
  {
    key: '5',
    name: '胡彦斌',
    age: 32,
    address: '西湖区湖底公园1号',
    tags: ['nice', 'developer'],
  },
  {
    key: '6',
    name: '长期&物资求助',
    age: 32,
    address: 'New York No. 1 Lake Park',
    tags: ['nice', 'developer'],
  },
  {
    key: '7',
    name: 'Jim Green',
    age: 42,
    address: 'London No. 1 Lake Park',
    tags: ['loser'],
  },
  {
    key: '8',
    name: 'Joe Black',
    age: 32,
    address: 'Sidney No. 1 Lake Park',
    tags: ['cool', 'teacher'],
  },
  {
    key: '9',
    name: '胡彦斌',
    age: 32,
    address: '西湖区湖底公园1号',
    tags: ['nice', 'developer'],
  },
  {
    key: '10',
    name: '长期&物资求助',
    age: 32,
    address: 'New York No. 1 Lake Park',
    tags: ['nice', 'developer'],
  },
  {
    key: '11',
    name: 'Jim Green',
    age: 42,
    address: 'London No. 1 Lake Park',
    tags: ['loser'],
  },
  {
    key: '12',
    name: 'Joe Black',
    age: 32,
    address: 'Sidney No. 1 Lake Park',
    tags: ['cool', 'teacher'],
  },
];

const columns2 = [
  {
    title: 'Name',
    dataIndex: 'name',
    key: 'name',
    render: (
      text:
        | boolean
        | ReactChild
        | ReactFragment
        | ReactPortal
        | null
        | undefined,
    ) => <a>{text}</a>,
  },
  {
    title: 'Age',
    dataIndex: 'age',
    key: 'age',
  },
  {
    title: 'Address',
    dataIndex: 'address',
    key: 'address',
  },
  {
    title: 'Tags',
    key: 'tags',
    dataIndex: 'tags',
    render: (tags: any[]) => (
      <>
        {tags.map((tag) => {
          let color = tag.length > 5 ? 'geekblue' : 'green';
          if (tag === 'loser') {
            color = 'volcano';
          }
          return (
            <Tag color={color} key={tag}>
              {tag.toUpperCase()}
            </Tag>
          );
        })}
      </>
    ),
  },
  {
    title: 'Action',
    key: 'action',
    render: (
      text: any,
      record: {
        name:
          | boolean
          | ReactChild
          | ReactFragment
          | ReactPortal
          | null
          | undefined;
      },
    ) => (
      <Space size="middle">
        <a>Invite {record.name}</a>
        <a>Delete</a>
      </Space>
    ),
  },
];

const data2 = [
  {
    key: '1',
    name: '胡彦斌',
    age: 32,
    address: '西湖区湖底公园1号',
    tags: ['nice', 'developer'],
  },
  {
    key: '2',
    name: '当地紧急求助',
    age: 32,
    address: 'New York No. 1 Lake Park',
    tags: ['nice', 'developer'],
  },
  {
    key: '3',
    name: 'Jim Green',
    age: 42,
    address: 'London No. 1 Lake Park',
    tags: ['loser'],
  },
  {
    key: '4',
    name: 'Joe Black',
    age: 32,
    address: 'Sidney No. 1 Lake Park',
    tags: ['cool', 'teacher'],
  },
  {
    key: '5',
    name: '胡彦斌',
    age: 32,
    address: '西湖区湖底公园1号',
    tags: ['nice', 'developer'],
  },
  {
    key: '6',
    name: '当地紧急求助',
    age: 32,
    address: 'New York No. 1 Lake Park',
    tags: ['nice', 'developer'],
  },
  {
    key: '7',
    name: 'Jim Green',
    age: 42,
    address: 'London No. 1 Lake Park',
    tags: ['loser'],
  },
  {
    key: '8',
    name: 'Joe Black',
    age: 32,
    address: 'Sidney No. 1 Lake Park',
    tags: ['cool', 'teacher'],
  },
  {
    key: '9',
    name: '胡彦斌',
    age: 32,
    address: '西湖区湖底公园1号',
    tags: ['nice', 'developer'],
  },
  {
    key: '10',
    name: '当地紧急求助',
    age: 32,
    address: 'New York No. 1 Lake Park',
    tags: ['nice', 'developer'],
  },
  {
    key: '11',
    name: 'Jim Green',
    age: 42,
    address: 'London No. 1 Lake Park',
    tags: ['loser'],
  },
  {
    key: '12',
    name: 'Joe Black',
    age: 32,
    address: 'Sidney No. 1 Lake Park',
    tags: ['cool', 'teacher'],
  },
];

export { columns1, data1, columns2, data2 };
